package com.hr.剑指offer.work1;

/**
 * @author 周恒哲
 * @date 2020/06/16
 **/
public class 面试题18_删除链表的节点 {

    public ListNode deleteNode(ListNode head, int val) {
        if(head.val==val){
            return head.next;
        }
        ListNode pre=head;
        ListNode cur=head.next;
        while (cur!=null&&cur.val!=val){
            pre=cur;
            cur=cur.next;
        }
        if (cur!=null){
            pre.next=cur.next;
        }
        return head;
    }
}
